package com.test.controller;


import com.test.entity.*;
import com.test.service.ManagerOperatService;
import com.test.service.StuOperatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/manOperat")
public class ManagerOperatController extends BaseController{

    @Autowired
    private ManagerOperatService managerOperatService;


    @RequestMapping("/selectAlltea")
    @ResponseBody
    public List<TeaAllInfoDto> selectAlltea(TeaAllInfoDto teaAllInfoDto){
        List<TeaAllInfoDto>  tealist = managerOperatService.selectAlltea(teaAllInfoDto);
        return tealist;
    }


    @RequestMapping("/selectAllcomp")
    @ResponseBody
    public List<CompAllInfoDto> selectAllcomp(CompAllInfoDto compAllInfoDto){
        List<CompAllInfoDto>  tealist = managerOperatService.selectAllcomp(compAllInfoDto);
        return tealist;
    }



    @RequestMapping("/disableUser")
    @ResponseBody
    public String disableUser(String u_acount){
        if(u_acount!=null&&!"undefined".equals(u_acount)&&!"".equals(u_acount)){
            int result =  managerOperatService.disableUser(u_acount);
            if (result>0){
                return "禁用成功";
            }else{
                return "禁用失败";
            }
        }else{
            return "禁用失败";
        }
    }

    @RequestMapping("/enableUser")
    @ResponseBody
    public String enableUser(String u_acount){
        if(u_acount!=null&&!"undefined".equals(u_acount)&&!"".equals(u_acount)){
            int result =  managerOperatService.enableUser(u_acount);
            if (result>0){
                return "禁用成功";
            }else{
                return "禁用失败";
            }
        }else{
            return "禁用失败";
        }
    }



    @RequestMapping("/selectTeaByStuCode")
    @ResponseBody
    public List<TeaAllInfoDto> selectTeaByStuCode(String u_acount){

        List<TeaAllInfoDto> tealist = managerOperatService.selectTeaByStuCode(u_acount);
        if (tealist.size()>0){
            return tealist;
        }else{
            return null;
        }
    }

    @RequestMapping("/selectCompByCode")
    @ResponseBody
    public List<CompAllInfoDto> selectCompByCode(String u_acount){

        List<CompAllInfoDto> complist = managerOperatService.selectCompByCode(u_acount);
        if (complist.size()>0){
            return complist;
        }else{
            return null;
        }
    }



    @RequestMapping("/selectPeidata")
    @ResponseBody
    public List<Map<String,Object>> selectPeidata(){
        List<Map<String,Object>> peidatalist = managerOperatService.selectPeidata();
       return peidatalist;
    }


    @RequestMapping("/SelectEmploymentRanking")
    @ResponseBody
    public List<Map<String,Object>> SelectEmploymentRanking(){
        List<Map<String,Object>> peidatalist = managerOperatService.SelectEmploymentRanking();
        return peidatalist;
    }


    @RequestMapping("/SelectEmploymentAddress")
    @ResponseBody
    public List<Map<String,Object>> SelectEmploymentAddress(){
        List<Map<String,Object>> peidatalist = managerOperatService.SelectEmploymentAddress();
        return peidatalist;
    }


    @RequestMapping("/SelectcollegeProportionPei")
    @ResponseBody
    public List<Map<String,Object>> SelectcollegeProportionPei(){
        List<Map<String,Object>> peidatalist = managerOperatService.SelectcollegeProportionPei();
        return peidatalist;
    }


    @RequestMapping("/SelectcollegeJobProportionPei")
    @ResponseBody
    public List<Map<String,Object>> SelectcollegeJobProportionPei(){
        List<Map<String,Object>> peidatalist = managerOperatService.SelectcollegeJobProportionPei();
        return peidatalist;
    }



    @RequestMapping("/SelectcollegeFurtherProportionPei")
    @ResponseBody
    public List<Map<String,Object>> SelectcollegeFurtherProportionPei(){
        List<Map<String,Object>> peidatalist = managerOperatService.SelectcollegeFurtherProportionPei();
        return peidatalist;
    }

    //管理员信息发布
    @RequestMapping("/submitNewsPortal")
    @ResponseBody
    public String submitNewsPortal(HttpSession session,NewsPortalDto newsPortalDto){
        String acount  = session.getAttribute("mana_u_acount").toString();
        newsPortalDto.setU_acount(acount);
        int result = 0;
        if(newsPortalDto.getNews_headline()!=null&&!"".equals(newsPortalDto.getNews_headline())){
            result  = managerOperatService.submitNewsPortal(newsPortalDto);
        }else{
            result = 0;
        }
        if(result>0){
            return "发布成功";
        }else{
            return "发布失败";
        }

    }

    //查询所有发布新闻
    @RequestMapping("/selectAllNewsPortal")
    @ResponseBody
    public List<NewsPortalDto> selectAllNewsPortal(String news_headline){
        List<NewsPortalDto> peidatalist = managerOperatService.selectAllNewsPortal(news_headline);
        return peidatalist;
    }




    //查询所有就业学生
    @RequestMapping("/selectAllemploymentRanking")
    @ResponseBody
    public List<Map<String,Object>> selectAllemploymentRanking(){
        List<Map<String,Object>> peidatalist = managerOperatService.selectAllemploymentRanking();
        return peidatalist;
    }


    //查询所有企业动态
    @RequestMapping("/selectAllentreprisesNews")
    @ResponseBody
    public List<ReleaseJobDto> selectAllentreprisesNews(String recruit_name){
        List<ReleaseJobDto> peidatalist = managerOperatService.selectAllentreprisesNews(recruit_name);

        return peidatalist;
    }




}
